{extend name="public/layout" /}
{block name="head"}{/block}
{block name="body"}

<body>
  <div class="container-fluid p-t-15">
    <div class="card">
      <div class="card-header card-header-sm">
        <form id="search-form" class="form-inline">
          <div class="form-group">
            <select class="form-control" name="search_field">
              <option value="patch_sn">碎片编号</option>
              <option value="patch_title">碎片标题</option>
            </select>
          </div>
          <div class="form-group">
            <input type="text" class="form-control" name="search_value" />
          </div>
          <button type="button" onclick="helper.refreshTable()" id="search-btn" class="btn btn-default">
            <i class="mdi mdi-magnify"></i> 搜索
          </button>
        </form>
      </div>
      <div class="p-lr-15">
        <div class="toolbar">
          <a href="javascript:void(0);" onclick="doAction.add();" class="btn btn-primary"><i class="mdi mdi-plus"></i>
            添加</a>
        </div>
        <div class="table-responsive">
          <table id="grid" class="table">
            <thead>
              <tr>
                <th data-field="id" data-width="50">ID</th>
                <th data-field="patch_type_str" data-width="160">碎片类型</th>
                <th data-field="patch_sn" data-width="160">碎片编号</th>
                <th data-field="patch_title">碎片标题</th>
                <th data-field="fun" data-width="220" data-formatter="doAction.formatterFun">调用方式</th>
                <th data-field="show_order" data-width="100">排序</th>
                <th data-field="operate" data-width="180" data-formatter="doAction.formatterOperate">操作</th>
              </tr>
            </thead>
          </table>
        </div>
      </div>
    </div>
  </div>
  <script>
    helper.bootstrapTable({
      sortName: "show_order",
      sortOrder: "asc",
      url: "index.html"
    });
    var doAction = {
      add: function () {
        helper.createTab({
          title: '添加碎片',
          url: '/system/patch/add.html'
        });
      },
      edit: function (id) {
        helper.createTab({
          title: '编辑碎片',
          url: '/system/patch/edit.html?id=' + id
        });
      },
      formatterFun: function (value, row, index) {
        return '<span class="text-danger">patch("' + row.patch_sn + '")</span>'
      },
      formatterOperate: function (value, row, index) {
        var html = '';
        html += '<a href="javascript:void(0);"  class="btn-xs btn btn-primary" onclick="doAction.edit(' + row.id + ')">' +
          '<i class="mdi mdi-pencil"></i> 编辑</a> ';
        html += '<a href="javascript:void(0)" class="btn-xs btn btn-danger" onclick="helper.doConfirm(this)"' +
          ' data-url="del.html" data-params="id=' + row.id + '" ' +
          'data-msg="确认删除吗?"><i class="mdi mdi-archive"></i> 删除</a>';
        return html;
      }
    };
  </script>
</body>
{/block}